package kr.or.kiso.controller;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

@SuppressWarnings("unchecked")
@Controller
public class KisoController
{
	@Autowired
	protected KisoService kisoService;
	
	@RequestMapping(value="/", method=RequestMethod.GET)
	public String index()
	{
		return "template";
	}
	
	@RequestMapping(value="/login", method=RequestMethod.POST)
	public String login(@RequestParam Map request, Map modelMap)
	{
		Map parameter = new HashMap();
		parameter.put("id",request.get("id"));
		parameter.put("password",request.get("password"));
		
		kisoService.list("login", "login", modelMap, parameter);
		System.out.println(modelMap.get("login"));
		
		return "login/loginForm";
	}
	
	@RequestMapping(value="/logout", method=RequestMethod.GET)
	public String logout()
	{
		return "login/logoutForm";
	}
	
	@RequestMapping(value="/loginCheck", method=RequestMethod.GET)
	public String loginCheck(@RequestParam Map request, Map modelMap)
	{
		Map parameter = new HashMap();
		parameter.put("id",request.get("id"));
		
		kisoService.list("loginCheck", "loginCheck", modelMap, parameter);
		
		return "template";
	}
	
	@RequestMapping(value="/loginInput", method=RequestMethod.POST)
	public String loginInput()
	{
		
		
		return "template";
	}
}
